<template>
  <div class="mainpg">
    <div class="main_spac1" style="padding-bottom:5px;">
      <div class="main_white padding10">
        
        <div class="main_table" style="min-height:690px">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="list"
            element-loading-text="加载中"
            fit
            highlight-current-row
          >
            <el-table-column label="序号" width="200">
              <template slot-scope="scope">{{scope.$index+1}}</template>
            </el-table-column>
            <el-table-column label="客户类型" prop="name" :show-overflow-tooltip="true" />
            <el-table-column
              label="管理操作"
              align="center"
              fixed="right"
              width="250"
              class-name="main_hei"
            >
			<template slot-scope="scope">
				<router-link :to="'/user/maintenanceMenu/'+scope.row.id">
                  <el-link type="warning">维护菜单</el-link>
                </router-link>
				<!-- <el-button @click="toMainMenu(scope.type)"  type="text" size="mini" class="handle_btn">维护菜单</el-button> -->
			</template>

            </el-table-column>
          </el-table>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
import { menuType } from "@/api/user/userMenu";
import rules from "@/rules/global/globalRole";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";

export default {
  components: {},
  data() {
    return {
      // 增加和编辑
      info: {
        name: "",
        remark: "",
      },
      type: 0,
      id: 0,
      addedFormVisible: false,
      // 验证
      rules,
      // 列表数据
      list:[],
      listLoading: false,
    };
  },
  methods: {
	  	//去维护菜单
		toMainMenu(type){
		},
		//新增菜单
		newMenu(){
			this.$router.push(
				
			)
		},
		// 关闭清空表单
		close(){
			this.info={
				name: "",
				remark: "",
			}
			this.$refs["userListFrom"].clearValidate();
		},

		// 新增保存
		add() {
		let data = Object.assign(
			{
			sign: Md5(
				objKeySort(Object.assign(apiUrl().name, this.info)) +
				apiUrl().appsecret
			),
			},
			apiUrl().name,
			this.info
		);
		role_add(data).then((res) => {
			this.addedFormVisible = false;
			if (res.errcode == 0) {
			this.$message({
				message: "新增成功",
				type: "success",
			});
			this.current.page = 1;
			this.getData();
			} else {
			this.$message.error(res.errmsg);
			}
		});
		},
		// 编辑保存
		edit() {
		let data = Object.assign(
			{
			sign: Md5(
				objKeySort(
				Object.assign(apiUrl().name, this.info, { id: this.id })
				) + apiUrl().appsecret
			),
			},
			apiUrl().name,
			this.info,
			{ id: this.id }
		);
		
		role_edit(data).then((res) => {
			this.addedFormVisible = false;
			if (res.errcode == 0) {
			this.$message({
				message: "编辑成功",
				type: "success",
			});
			this.getData();
			} else {
			this.$message.error(res.errmsg);
			}
		});
		},
		// 列表
		getData() {
			this.listLoading = true;
			let data = Object.assign(
				{
					sign: Md5(
						objKeySort(Object.assign(apiUrl().name)) +
						apiUrl().appsecret
					),
				},
				apiUrl().name,
			);
			menuType(data).then((res) => {
				this.listLoading = false;
				if (res.errcode == 0) {
					this.list = res.data;
				} else {
					this.$message.error(res.errmsg);
				}
			});
		},
	},
	created() {
		// 列表
		this.getData();
	},
};
</script>
<style lang="scss" scoped>
.handle_btn{
	padding:0;
	border:0;
}
</style>
